#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int T,n,a[200005],c[200005],tmp;
bool flag,cl[200005];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T>0){
        ull ans=0;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
        sort(a+1,a+n+1);
        for(int i=1;i<=n;i+=2){
            if(a[i]==a[i+1])    ans+=a[i];
        }
        cout<<ans<<endl;
        T--;
    }
    return 0;
}
